<template>
  <view v-show="!isLoading" class="container" :style="appThemeStyle">
    <!-- 固定顶部导航栏 - 滚动时显示 -->
    <view class="sticky-tabs" :class="{ 'sticky-tabs-visible': showStickyTabs }">
      <view class="tab-item" :class="{ active: activeTab === 'product' }" @click="scrollToSection('product')">
        <text>商品</text>
      </view>
	  <view class="tab-item" :class="{ active: activeTab === 'comment' }" @click="scrollToSection('comment')">
	    <text>评论</text>
	  </view>
      <view class="tab-item" :class="{ active: activeTab === 'detail' }" @click="scrollToSection('detail')">
        <text>详情</text>
      </view>
    </view>

    <!-- 商品部分 -->
    <view id="product-section" ref="productSection">
      <!-- 商品图片轮播 -->
      <SlideImage v-if="!isLoading" :video="goods.video" :videoCover="goods.videoCover" :images="goods.goods_images" />

      <!-- 商品信息 -->
      <view v-if="!isLoading" class="goods-info">
        <!-- 价格、销量 -->
        <view class="info-item info-item__top dis-flex flex-x-between flex-y-end">
          <view class="block-left dis-flex flex-y-center">
            <!-- 商品售价 -->
            <text class="floor-price__samll">￥</text>
            <text class="floor-price">{{ goods.goods_price_min }}</text>
            <!-- 会员价标签 -->
            <view v-if="goods.is_user_grade" class="user-grade">
              <text>会员价</text>
            </view>
            <!-- 划线价 -->
            <text v-if="goods.line_price_min > 0" class="original-price">￥{{ goods.line_price_min }}</text>
          </view>
          <view class="block-right dis-flex">
            <!-- 销量 -->
            <view class="goods-sales">
              <text>已售{{ goods.goods_sales }}件</text>
            </view>
          </view>
        </view>
        <!-- 标题、分享 -->
        <view class="info-item info-item__name dis-flex flex-y-center">
          <view class="goods-name flex-box">
            <text class="twoline-hide">{{ goods.goods_name }}</text>
          </view>
          <view class="goods-share__line"></view>
          <view class="goods-share">
            <button class="share-btn dis-flex flex-dir-column" @click="onShowShareSheet()">
              <text class="share__icon iconfont icon-fenxiang"></text>
              <text class="f-24">分享</text>
            </button>
          </view>
        </view>
        <!-- 商品卖点 -->
        <view v-if="goods.selling_point" class="info-item info-item_selling-point">
          <text>{{ goods.selling_point }}</text>
        </view>
      </view>

      <!-- 商品服务 -->
      <Service v-if="!isLoading" :goods-id="goodsId" />

      <!-- 选择商品规格 -->
      <view v-if="goods.spec_type == 20" class="goods-choice" @click="onShowSkuPopup(1)">
        <view class="spec-list">
          <view class="flex-box">
            <text class="col-8">选择：</text>
            <text class="spec-name" v-for="(item, index) in goods.specList" :key="index">{{ item.spec_name }}</text>
          </view>
          <view class="f-26 col-9 t-r">
            <text class="iconfont icon-arrow-right"></text>
          </view>
        </view>
      </view>
    </view>
	
	<!-- 评论部分 -->
	<view id="comment-section" ref="commentSection" class="comment-section">
	  <!-- 使用抽离出来的评价组件 -->
    <view class="review-header" @click="handlePopup">
      <view class="review-title">
        <text class="review-count">买家评价(2000+)</text>
      </view>
      <view class="review-more">
        <text class="review-rate">超97%买家赞不绝口</text>
        <text class="iconfont icon-arrow-right"></text>
      </view>
    </view>
	</view>

    <!-- 详情部分 -->
    <view id="detail-section" ref="detailSection" class="detail-section">
      <!-- 基本信息表格 -->
      <view class="specs-table">
        <view class="specs-header">
          <text>基本信息</text>
        </view>
        
        <view class="specs-table-content">
          <!-- 统一社会信用代码 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>统一社会信用代码</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.code || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 企业名称 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>企业名称</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.company_name || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 法定代表人 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>法定代表人</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.legal_representative || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 登记状态 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>登记状态</text>
            </view>
            <view class="specs-cell specs-value">
              <text class="status-tag" :class="goods.registration_status === '正常' ? 'status-normal' : 'status-abnormal'">
                {{ goods.registration_status || '暂无数据' }}
              </text>
            </view>
          </view>

          <!-- 企业类型 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>企业类型</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.company_type || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 纳税人资质 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>纳税人资质</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.taxpayer_qualification || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 人员规模 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>人员规模</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.staff_size || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 参保人数 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>参保人数</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.social_insurance_count || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 成立日期 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>成立日期</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.established_date || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 核准日期 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>核准日期</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.approved_date || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 营业期限 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>营业期限</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ (goods.business_term_start && goods.business_term_end) ? 
                `${goods.business_term_start} 至 ${goods.business_term_end}` : '暂无数据' }}</text>
            </view>
          </view>

          <!-- 所属地区 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>所属地区</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.registered_region || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 登记机关 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>登记机关</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.registration_authority || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 英文名 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>英文名</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.english_name || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 注册地址 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>注册地址</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.registered_address || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 注册地址邮编 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>注册地址邮编</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.registered_address_postcode || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 通信地址 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>通信地址</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.mailing_address || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 通信地址邮编 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>通信地址邮编</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.mailing_address_postcode || '暂无数据' }}</text>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 车牌情况 - 新增表格 -->
      <view class="specs-table">
        <view class="specs-header">
          <text>车牌情况</text>
        </view>
        <view class="specs-table-content">
          <!-- 燃油车牌数量 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>燃油车牌数量</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.fuel_vehicle_license || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 电动车牌数量 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>电动车牌数量</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.electric_vehicle_license || '暂无数据' }}</text>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 近三年财务情况 - 新增表格 -->
      <view class="specs-table">
        <view class="specs-header">
          <text>近三年财务情况</text>
        </view>
        <view class="specs-table-content">
          <!-- 营业收入总额 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>营业收入总额</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.total_operating_revenue || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 收入增长率 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>收入增长率(同比%)</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.revenue_growth_rate_yoy || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 现金流净额 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>现金流净额</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.net_cash_flow || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 纳税总额 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>纳税总额(万元)</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.total_tax_payment || '暂无数据' }}</text>
            </view>
          </view>

          <!-- 实际税负率 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>实际税负率(%)</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.effective_tax_rate || '暂无数据' }}</text>
            </view>
          </view>
          
          <!-- 税收优惠/减免 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>税收优惠/减免</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.tax_incentives_and_reliefs || '暂无数据' }}</text>
            </view>
          </view>
          
          <!-- 滞纳金/罚款 -->
          <view class="specs-row">
            <view class="specs-cell specs-label">
              <text>滞纳金/罚款</text>
            </view>
            <view class="specs-cell specs-value">
              <text>{{ goods.late_payment_penalties || '暂无数据' }}</text>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 经营范围 - 单独表格 -->
      <view class="specs-table">
        <view class="specs-header">
          <text>经营范围</text>
        </view>
        <view class="table-active">
          <view class="specs-row specs-active">
            <view class="specs-cell specs-value full-width specstext-active">
              <view :class="{ 'indent-container': goods.business_scope }">
                <text class="multi-line">{{ goods.business_scope || '暂无数据' }}</text>
              </view>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 资质状况 - 单独表格 -->
      <view class="specs-table">
        <view class="specs-header">
          <text>资质状况</text>
        </view>
        <view class="table-active">
          <view class="specs-row specs-active">
            <view class="specs-cell specs-value full-width specstext-active">
              <text class="multi-line">{{ goods.qualification_status || '暂无数据' }}</text>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 知识产权 - 单独表格 -->
      <view class="specs-table">
        <view class="specs-header">
          <text>知识产权</text>
        </view>
        <view class="table-active">
          <view class="specs-row specs-active">
            <view class="specs-cell specs-value full-width specstext-active">
              <text class="multi-line">{{ goods.intellectual_property_rights || '暂无数据' }}</text>
            </view>
          </view>
        </view>
      </view>

      <!-- 商品描述 -->
      <view v-if="!isLoading" class="goods-content">
        <view class="content-header">
          <text>商品描述</text>
        </view>
        <view class="goods-content__detail" :class="{ 'indent-acctive': goods.content }">
          <mp-html v-if="goods.content" :content="goods.content" />
		  <text v-else class="no-data">暂无数据</text>
        </view>
      </view>
    </view>

    <!-- 商品SKU弹窗 -->
    <view class="sku-popup-wrapper" v-if="showSkuPopup">
      <SkuPopup v-if="!isLoading" v-model="showSkuPopup" :skuMode="skuMode" :goods="goods" @addCart="onAddCart" />
    </view>

    <!-- 底部选项卡 -->
    <view class="footer-fixed">
      <view class="footer-container">
        <!-- 导航图标 -->
        <view class="foo-item-fast">
          <!-- 首页 -->
          <view class="fast-item fast-item--home" @click="onTargetHome">
            <view class="fast-icon">
              <text class="iconfont icon-shouye"></text>
            </view>
            <view class="fast-text">
              <text>首页</text>
            </view>
          </view>
          <!-- 客服 -->
          <customer-btn v-if="isShowCustomerBtn" :showCard="true" :cardTitle="goods.goods_name" :cardImage="goods.goods_image"
            :cardPath="pagePath">
            <view class="fast-item">
              <view class="fast-icon">
                <text class="iconfont icon-kefu1"></text>
              </view>
              <view class="fast-text">
                <text>客服</text>
              </view>
            </view>
          </customer-btn>
          <!-- 购物车 -->
          <view class="fast-item fast-item--cart" @click="onTargetCart">
            <view v-if="cartTotal > 0" class="fast-badge fast-badge--fixed">{{ cartTotal > 99 ? '99+' : cartTotal }}
            </view>
            <view class="fast-icon">
              <text class="iconfont icon-gouwuche"></text>
            </view>
            <view class="fast-text">
              <text>购物车</text>
            </view>
          </view>
        </view>
        <!-- 操作按钮 -->
        <view class="foo-item-btn">
          <view class="btn-wrapper">
            <view v-if="isEnableCart" class="btn-item btn-item-deputy" @click="onShowSkuPopup(2)">
              <text>加入购物车</text>
            </view>
            <view class="btn-item btn-item-main" @click="onShowSkuPopup(3)">
              <text>立即购买</text>
            </view>
          </view>
        </view>
      </view>
    </view>

    <!-- 分享菜单 -->
    <share-sheet v-model="showShareSheet" :shareTitle="goods.goods_name" :shareImageUrl="goods.goods_image" />

  </view>
</template>

<script>
  import { getSceneData } from '@/core/app'
  import * as GoodsApi from '@/api/goods'
  import * as CartApi from '@/api/cart'
  import SettingModel from '@/common/model/Setting'
  import { GoodsTypeEnum } from '@/common/enum/goods'
  import ShareSheet from '@/components/share-sheet'
  import CustomerBtn from '@/components/customer-btn'
  import SlideImage from './components/SlideImage.vue'
  import SkuPopup from './components/SkuPopup.vue'
  import Comment from './components/Comment.vue'
  import Service from './components/Service.vue'
  import ReviewPopup from './components/ReviewPopup.vue' // 导入新的评价组件

  export default {
    components: {
      ShareSheet,
      CustomerBtn,
      SlideImage,
      SkuPopup,
      Comment,
      Service,
      ReviewPopup // 注册评价组件
    },
    data() {
      return {
        // 正在加载
        isLoading: true,
        // 当前商品ID
        goodsId: null,
        // 商品详情
        goods: {},
        // 购物车总数量
        cartTotal: 0,
        // 显示/隐藏SKU弹窗
        showSkuPopup: false,
        // 模式 1:都显示 2:只显示购物车 3:只显示立即购买
        skuMode: 1,
        // 显示/隐藏分享菜单
        showShareSheet: false,
        // 是否支持加入购物车
        isEnableCart: false,
        // 是否显示在线客服按钮
        isShowCustomerBtn: false,
        // 展开的部分
        expandedSections: {
          registration: false,
          address: false,
          business: false,
          finance: false,
          tax: false,
          qualification: false
        },
        // 是否显示固定顶部导航
        showStickyTabs: false,
        // 当前激活的标签
        activeTab: 'product',
        // 各部分的位置信息
        sectionOffsets: {
          product: 0,
          detail: 0,
          comment: 0
        }
      }
    },
    computed: {
      // 当前页面链接
      pagePath() {
        const params = this.$getShareUrlParams({ goodsId: this.goodsId })
        return `/pages/goods/detail?${params}`
      }
    },
    methods: {
      // 记录query参数
      onRecordQuery(query) {
        const scene = getSceneData(query)
        this.goodsId = query.goodsId ? parseInt(query.goodsId) : parseInt(scene.gid)
      },

      // 刷新页面数据
      onRefreshPage() {
        const app = this
        app.isLoading = true
        Promise.all([app.getGoodsDetail(), app.getCartTotal()])
          .finally(() => {
            app.isLoading = false
            // 数据加载完成后，计算各部分的位置
            app.$nextTick(() => {
              setTimeout(() => {
                app.calculateSectionOffsets()
              }, 500)
            })
          })
      },

      // 获取商品信息
      getGoodsDetail() {
        const app = this
        return new Promise((resolve, reject) => {
          GoodsApi.detail(app.goodsId)
            .then(result => {
              app.goods = result.data.detail
              if (app.goods.goods_type == GoodsTypeEnum.PHYSICAL.value) {
                app.isEnableCart = true
              }
              resolve(result)
            })
            .catch(reject)
        })
      },

      // 获取购物车总数量
      getCartTotal() {
        const app = this
        return new Promise((resolve, reject) => {
          CartApi.total()
            .then(result => {
              app.cartTotal = result.data.cartTotal
              resolve(result)
            })
            .catch(reject)
        })
      },

      // 更新购物车数量
      onAddCart(total) {
        this.cartTotal = total
      },

      // 切换部分的展开/折叠状态
      toggleSection(section) {
        this.expandedSections[section] = !this.expandedSections[section]
        // 展开/折叠后，重新计算各部分的位置
        this.$nextTick(() => {
          setTimeout(() => {
            this.calculateSectionOffsets()
          }, 300)
        })
      },

      // 格式化分号分隔的列表，使其更易读
      formatSemicolonList(text) {
        if (!text) return '';
        // 将分号分隔的文本转换为带有项目符号的格式
        return text.split(';').map(item => '• ' + item.trim()).join('\n');
      },
	  
	  // 格式化经营范围，支持换行
	  formatIndentText(text) {
	    if (!text) return '';
	    return text.replace(/;/g, ';\n');
	  },

      // 计算各部分的位置
      calculateSectionOffsets() {
        // 使用页面内的绝对位置
        const query = uni.createSelectorQuery().in(this)
        query.selectViewport().scrollOffset() // 获取页面滚动位置
        
        // 获取各部分的位置
        query.select('#product-section').boundingClientRect()
        query.select('#comment-section').boundingClientRect()
        query.select('#detail-section').boundingClientRect()
        
        query.exec(res => {
          const pageScrollTop = res[0].scrollTop // 当前页面滚动位置
          
          // 确保按照DOM顺序获取各部分位置
          if (res[1]) {
            this.sectionOffsets.product = pageScrollTop + res[1].top
            console.log('Product section offset:', this.sectionOffsets.product)
          }
          
          if (res[2]) {
            this.sectionOffsets.comment = pageScrollTop + res[2].top
            console.log('Comment section offset:', this.sectionOffsets.comment)
          }
          
          if (res[3]) {
            this.sectionOffsets.detail = pageScrollTop + res[3].top
            console.log('Detail section offset:', this.sectionOffsets.detail)
          }
          
          // 确保各部分的位置是按照从小到大的顺序排列
          console.log('Section offsets:', this.sectionOffsets)
        })
      },

      // 根据滚动位置更新当前激活的标签
      updateActiveTab(scrollTop) {
        // 获取当前页面滚动位置
        const currentScrollTop = scrollTop + 100 // 基础偏移量
        
        // 添加额外的延迟偏移量，让高亮切换发生在更靠近内容区域的位置
        const highlightOffset = 80; // 可以根据实际效果调整这个值
        
        // 根据DOM结构顺序调整条件判断顺序
        // 实际DOM结构是：product -> comment -> detail
        if (currentScrollTop >= (this.sectionOffsets.detail + highlightOffset)) {
          this.activeTab = 'detail'
        } else if (currentScrollTop >= (this.sectionOffsets.comment + highlightOffset)) {
          this.activeTab = 'comment'
        } else {
          this.activeTab = 'product'
        }
      },

      // 滚动到指定部分
      scrollToSection(section) {
        let selector = ''
        switch (section) {
          case 'product':
            selector = '#product-section'
            break
          case 'detail':
            selector = '#detail-section'
            break
          case 'comment':
            selector = '#comment-section'
            break
        }
        
        if (selector) {
          // 使用页面内的绝对位置，而不是相对于视口的位置
          const query = uni.createSelectorQuery().in(this)
          query.selectViewport().scrollOffset() // 获取页面滚动位置
          query.select(selector).boundingClientRect()
          query.exec(res => {
            if (res[1]) {
              const pageScrollTop = res[0].scrollTop // 当前页面滚动位置
              const elementTop = res[1].top // 元素相对于视口的位置
              
              // 为不同的部分设置不同的偏移量
              let offset = 50; // 默认偏移量
              if (section === 'detail' || section === 'comment') {
                offset = 0; // 详情和评论部分使用更大的偏移量
              }
              
              const scrollPosition = pageScrollTop + elementTop - offset // 计算绝对位置并减去偏移高度
              
              uni.pageScrollTo({
                scrollTop: scrollPosition,
                duration: 150
              })
            }
          })
        }
      },

      /**
       * 显示/隐藏SKU弹窗
       * @param {skuMode} 模式 1:都显示 2:只显示购物车 3:只显示立即购买
       */
      onShowSkuPopup(skuMode = 1) {
        const app = this
        if (app.isEnableCart) {
          app.skuMode = skuMode
        } else {
          app.skuMode = 3
        }
        app.showSkuPopup = !app.showSkuPopup
      },

      // 显示隐藏分享菜单
      onShowShareSheet() {
        this.showShareSheet = !this.showShareSheet
      },

      // 跳转到首页
      onTargetHome(e) {
        this.$navTo('pages/index/index')
      },

      // 跳转到购物车页
      onTargetCart() {
        this.$navTo('pages/cart/index')
      }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    async onLoad(options) {
      // 记录query参数
      this.onRecordQuery(options)
      // 加载页面数据
      this.onRefreshPage()
      // 是否显示在线客服按钮
      this.isShowCustomerBtn = await SettingModel.isShowCustomerBtn()
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
      // 页面显示后，计算各部分的位置
      this.$nextTick(() => {
        setTimeout(() => {
          this.calculateSectionOffsets()
        }, 500)
      })
    },

    /**
     * 页面滚动时触发
     */
    onPageScroll(e) {
      // 滚动位置超过商品部分时显示顶部导航
      this.showStickyTabs = e.scrollTop > 300
      
      // 根据滚动位置更新当前激活的标签
      this.updateActiveTab(e.scrollTop)
    },

    /**
     * 分享当前页面
     */
    onShareAppMessage() {
      return {
        title: this.goods.goods_name,
        path: this.pagePath
      }
    },

    /**
     * 分享到朋友圈
     * 本接口为 Beta 版本，暂只在 Android 平台支持，详见分享到朋友圈 (Beta)
     * https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
     */
    onShareTimeline() {
      return {
        title: this.goods.goods_name,
        path: this.pagePath
      }
    }
  }
</script>

<style>
  page {
    background: #f7f7f7;
  }
</style>
<style lang="scss" scoped>
  @import "./detail.scss";
  /* 评价区域 */
  .review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30rpx 24rpx 20rpx;
    background-color: #fff;
  }
  
  .review-title {
    font-size: 28rpx;
    font-weight: 500;
    color: #333;
    display: flex;
    align-items: center;
  }
  
  .review-count {
    font-size: 30rpx;
    color: #000;
    font-weight: bold;
    margin-left: 10rpx;
  }
  
  .review-more {
    display: flex;
    align-items: center;
  }
  
  .review-rate {
    font-size: 24rpx;
    color: #ff8f1f;
  }

  /* 固定顶部导航 */
  .sticky-tabs {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 88rpx;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 999;
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
  }

  .sticky-tabs-visible {
    transform: translateY(0);
  }

  .tab-item {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28rpx;
    color: #666;
    position: relative;
  }

  .tab-item.active {
	font-weight: bold;
	color: #000;
  }

  /* 商品信息样式 */
  .goods-info {
    background: #fff;
    padding: 40rpx 44rpx;
  }

  /* 详情部分 */
  .detail-section {
    margin-bottom: 20rpx;
  }

  /* 评论部分 */
  .comment-section {
    margin-bottom: 20rpx; /* 为底部导航留出空间 */
	margin-top: 20rpx;
  }

  /* 规格参数表格 */
  .specs-table {
    background-color: #fff;
    margin-bottom: 20rpx;
    overflow: hidden;
  }

  .specs-header {
    padding: 24rpx 40rpx;
    font-size: 30rpx;
    font-weight: 500;
    color: #333;
	font-weight: bold;
  }

  .specs-table-content {
    padding: 0;
    padding: 0 40rpx;
	padding-bottom: 20px;
  }

  .specs-row {
    display: flex;
    border-bottom: 1px solid #e7e7e9;
    border-right: 1px solid #e7e7e9;
    border-left: 1px solid #e7e7e9;
  }
  
  .specs-row:first-child {
    border-top: 1px solid #e7e7e9;
  }

  .specs-cell {
    padding: 24rpx 34rpx;
  }

  .specs-label {
    width: 270rpx;
    flex-shrink: 0;
    font-size: 23rpx;
    color: #98989a;
    border-right: 1px solid #e7e7e9;
  }

  .specs-value {
    flex: 1;
    font-size: 23rpx;
    color: #88888a;
    word-break: break-all;
  }
  
  .full-width {
    width: 100%;
  }

  .multi-line {
    white-space: pre-wrap;
    line-height: 1.5;
  }

  .status-tag {
    display: inline-block;
    border-radius: 4rpx;
    font-size: 23rpx;
  }

  .status-normal {
    background-color: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
  }

  /* 商品描述 */
  .goods-content {
    background-color: #fff;
    margin-bottom: 20rpx;
  }

  .content-header {
    padding: 24rpx 40rpx;
    font-size: 30rpx;
    font-weight: 500;
    color: #333;
	font-weight: bold;
  }

  .goods-content__detail {
    padding: 0rpx 60rpx 30rpx 60rpx;
  }
  
  .indent-acctive{
	  text-indent: 2em
  }

  /* 商品选择 */
  .goods-choice {
    background-color: #fff;
    padding: 24rpx;
    margin-bottom: 20rpx;
  }

  .spec-list {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .spec-name {
    margin-right: 16rpx;
    color: #333;
  }

  /* 底部按钮 */
  .footer-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100rpx;
    background-color: #fff;
    box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
    z-index: 1;
  }

  .footer-container {
    display: flex;
    height: 100%;
  }

  .foo-item-fast {
    display: flex;
    width: 40%;
  }

  .fast-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
  }

  .fast-icon {
    height: 40rpx;
    line-height: 40rpx;
  }

  .fast-text {
    font-size: 22rpx;
    color: #666;
  }

  .fast-badge {
    position: absolute;
    top: 0;
    right: 10rpx;
    background-color: #ff4d4f;
    color: #fff;
    font-size: 20rpx;
    padding: 0 8rpx;
    border-radius: 20rpx;
    min-width: 32rpx;
    height: 32rpx;
    line-height: 32rpx;
    text-align: center;
  }

  .foo-item-btn {
    flex: 1;
    display: flex;
    align-items: center;
    padding-right: 20rpx;
  }

  .btn-wrapper {
    display: flex;
    width: 100%;
    height: 80rpx;
  }

  .btn-item {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 28rpx;
    color: #fff;
    border-radius: 40rpx;
  }

  .btn-item-deputy {
    background-color: #ff9500;
    margin-right: 20rpx;
  }

  .btn-item-main {
    background-color: #ff4d4f;
  }
  
  .goods-name{
	  font-weight: bold;
  }
  
  .share__icon{
	  font-size: 18px !important;
  }
  
  .f-24{
	  font-size: 20rpx;
  }
  
  .business-scope-text {
    text-indent: 2em; /* 设置首行缩进为2个字符的宽度 */
    white-space: pre-wrap;
    line-height: 1.5;
  }
  
  /* 如果您已经有 .multi-line 类，可以修改它而不是创建新类 */
  /* 
  .multi-line {
    text-indent: 2em;
    white-space: pre-wrap;
    line-height: 1.5;
  }
  */
  
  .indent-container {
    text-indent: 2em; /* 将第一行拉回 */
  }
  
  .specs-active{
	  border: none;
	  border-top: none !important;
  }
  
  .specstext-active {
	  color: rgb(51, 51, 51);
	  font-size: 27rpx;
	  padding:20rpx 60rpx;
	  padding-bottom: 40rpx;
  }
  
  /* SKU弹窗包装器样式 */
  .sku-popup-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999; /* 确保高于底部导航栏 */
  }
  
  .no-data {
    color: #999;
    font-size: 26rpx;
    display: block;
    padding: 20rpx 0;
  }
  
  .table-active {
    padding: 0 40rpx;
    padding-bottom: 20px;
  }
</style>